package com.app.ytong.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.app.ytong.R;
import com.app.ytong.util.MyUtils;

import java.util.ArrayList;
import java.util.List;

public class MenuBean extends BasisBean {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	@JSONField(name = "id")
	private String id;
	@JSONField(name = "mna")
	private String mna;
	@JSONField(name = "sna")
	private String sna;
	@JSONField(name = "sele")
	private boolean sele;
	@JSONField(name = "path")
	private String path;
	@JSONField(name = "child")
	private List<MenuBean> child = new ArrayList<>();

	public String getMna() {
		return mna;
	}

	public void setMna(String mna) {
		this.mna = mna;
	}

	public boolean isSele() {
		return sele;
	}

	public void setSele(boolean sele) {
		this.sele = sele;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public List<MenuBean> getChild() {
		return child;
	}

	public void setChild(List<MenuBean> child) {
		this.child = child;
	}

	public String getSna() {
		return sna;
	}

	public void setSna(String sna) {
		this.sna = sna;
	}

	public int getBackGround(int position){
		switch (position){
			case 0:
				return R.drawable.home_index_btn_bg1;
			case 1:
				return R.drawable.home_index_btn_bg2;
			case 2:
				return R.drawable.home_index_btn_bg3;
			case 3:
				return R.drawable.home_index_btn_bg4;
			default:
				return R.drawable.home_index_btn_bg5;
		}
	}

	public MenuBean getIsSeleChild(){
		MenuBean menuBean = new MenuBean();
		switch (MyUtils.getTabSelectName()){
			case "出库":
				for(MenuBean data : child){
					if(data.getSna().contains("出库")){
						if (data.isSele()){
							menuBean.getChild().add(data);
						}
					}

				}
				break;
			case "入库":
				for(MenuBean data : child){
					if(data.getSna().contains("入库")){
						if (data.isSele()){
							menuBean.getChild().add(data);
						}
					}
				}
				break;
		}
		return menuBean;
	}


	public MenuBean getChildBySelectName(){
		MenuBean menuBean = new MenuBean();
		switch (MyUtils.getTabSelectName()){
			case "出库":
				for(MenuBean data : child){
					if(data.getSna().contains("出库")){
						if (data.isSele()){
							return  data;
						}
					}

				}
				break;
			case "入库":
				for(MenuBean data : child){
					if(data.getSna().contains("入库")){
						if (data.isSele()){
							return data;
						}
					}
				}
				break;
		}
		return menuBean;
	}

	public String getFsgByFromIn(){
		for(MenuBean data : child){
			if(data.getSna().contains("采购入库")){
				return   data.getId();
			}
		}

		return "";
	}

}
